<?php
namespace MyAdmin\Model;

use Think\Model;

class AppsModel extends Model
{
  public function storage_config($app_id)
  {
    if (!$app_id) {
      return false;
    }

    $app = M('apps')
      ->field('storage_type, qiniu_domain, qiniu_accesskey, qiniu_secretkey, qiniu_bucket, qiniu_area, oss_domain, oss_endpoint, oss_key, oss_secret, oss_bucket, upyun_host, upyun_bucket, upyun_username, upyun_password, upyun_endpoint')
      ->where("id=$app_id")->find();

    return $app;
  }

  public function sms_config($app_id)
  {
    if (!$app_id) {
      return false;
    }

    $app = M('apps')->where("id=$app_id")->find();
    $conifg = array(
      'sms_type' => $app['sms_type'],
      'appkey' => $app['smsct_appkey'],
      'secretKey' => $app['smsct_secretkey'],
      'signname' => $app['smsct_signname'],
      'templatecode' => $app['smsct_tpcode'],
      'ordertemplatecode' => $app['smsct_ordertpcode'],
      'refundtemplatecode' => $app['smsct_refundcode'],
      'zanwintemplatecode' => $app['smsct_zanwincode']
    );
    return $config;
  }
}
